#source("http://my-r-project-code.googlecode.com/svn/trunk/Vergl1.r")


## Script Procedure on windows
## INSTALL LIBRARIES
library(doBy);#  
#  set working directory
#setwd("w:/IMARES/IJmuiden/Afdeling/Projecten")
setwd("/media/n/Projecten"); #bearedo/Res/
length_haul <-  read.csv("http://my-r-project-code.googlecode.com/svn/trunk/length_haul.csv")
tot_haul <-  read.csv("http://my-r-project-code.googlecode.com/svn/trunk/tot_haul.csv")
head(tot_haul)
tot_haul$dutch_name<-as.character(tot_haul$dutch_name)
tot_haul[tot_haul$dutch_name=="",]$dutch_name <- as.character(tot_haul[tot_haul$dutch_name=="",]$scientific_name)
spec<-aggregate(list(NumbH=tot_haul$nha),list(species=tot_haul$dutch_name),sum)
spec<-orderBy(~-NumbH,data= spec)[c("species")][1:18,]
data<-tot_haul
file<-list()
for (SPECIES in spec) {
sel.SP<-cbind(data[data$dutch_name==SPECIES&data$tor_code=="Kuil08p",][c("nha")],
data[data$dutch_name==SPECIES&data$tor_code=="Boomkor04w",][c("nha")])
colnames(sel.SP)<-c("kuil","boom")
sel.SP$spe<-SPECIES
file<-rbind(file,sel.SP)
}
save(file,file="bearedo/Res/file.rda")
nha<-file[file$spe==spec[1],]
options(echo=TRUE);sink("results.log_int.txt")
pdf("some_graphs.log_int.pdf"); 
if (length(nha[nha$kuil==0,]$kuil)>0) nha[nha$kuil==0,]$kuil<-0.3
if (length(nha[nha$kuil==0,]$kuil)>0) nha[nha$boom==0,]$boom<-0.3
hist(nha[["boom"]],main=spec[1])
hist(log(nha[["boomw"]]),main=spec[1])
max(nha[,1])
max(nha[,2])
maxi<-(ifelse(max(nha.[,2])<max(nha[,1]),max(nha[,1]),max(nha[,2])))
max<-log(ifelse(max(nha[,2])<max(nha[,1]),max(nha[,1]),max(nha[,2])))

sink()
dev.off()
options(echo=TRUE)
